package o;

import android.content.Context;
import android.text.SpannableString;
import android.text.style.TextAppearanceSpan;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
import android.view.animation.Animation;
import android.view.animation.TranslateAnimation;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.TextView;
import o.aws.d;
import o.awx.a;
import o.axa.b;
import o.axa.f;
import o.axa.h;
import o.ayo.e;
import o.ckl.c;

public class axy extends LinearLayout {
    private FrameLayout ˊ;
    private axv ˋ;

    public axy(Context context) {
        this(context, 0);
    }

    public axy(Context context, int i) {
        View inflate;
        super(context);
        this.ˋ = axv.ˊ();
        if (i == 1) {
            inflate = LayoutInflater.from(context).inflate(f.ॱˎ, this, true);
        } else {
            inflate = LayoutInflater.from(context).inflate(f.ʽ, this, true);
        }
        this.ˊ = (FrameLayout) inflate.findViewById(b.ʿ);
        inflate = ॱ(context);
        View ˎ = ˎ(context);
        this.ˊ.addView(inflate);
        this.ˊ.addView(ˎ);
        setFocusable(true);
        setFocusableInTouchMode(true);
        if (this.ˋ.ॱ == 1) {
            inflate.setVisibility(8);
            ˎ.setVisibility(0);
        }
    }

    private View ॱ(Context context) {
        LayoutInflater from = LayoutInflater.from(context);
        LinearLayout linearLayout = (LinearLayout) from.inflate(f.ॱॱ, null);
        LinearLayout linearLayout2 = (LinearLayout) linearLayout.findViewById(b.ˋˋ);
        LinearLayout linearLayout3 = (LinearLayout) linearLayout.findViewById(b.ˋˊ);
        TextView textView = (TextView) linearLayout.findViewById(b.ˉ);
        TextView textView2 = (TextView) linearLayout.findViewById(b.ˊˋ);
        awr ॱ = axg.ˏ().ॱ();
        if (ॱ != null) {
            awq ॱ2 = ॱ.ॱ();
            if (ॱ2 != null) {
                LayoutParams layoutParams = new LinearLayout.LayoutParams(-2, -2);
                if (ॱ2.ˋ() != null) {
                    for (a aVar : ॱ2.ˋ()) {
                        LinearLayout linearLayout4 = (LinearLayout) from.inflate(f.ॱᐝ, null);
                        TextView textView3 = (TextView) linearLayout4.findViewById(b.ˏॱ);
                        TextView textView4 = (TextView) linearLayout4.findViewById(b.ͺ);
                        textView3.setText(aVar.ˏ);
                        textView4.setText(aVar.ˊ);
                        textView3.setLayoutParams(layoutParams);
                        linearLayout2.addView(linearLayout4);
                    }
                }
                if (ॱ2.ˊ() != null) {
                    for (String text : ॱ2.ˊ()) {
                        TextView textView5 = (TextView) from.inflate(f.ʻॱ, null);
                        textView5.setText(text);
                        textView5.setLayoutParams(layoutParams);
                        linearLayout3.addView(textView5);
                    }
                }
                textView.setText(ॱ2.ˎ());
                String text2 = ॱ2.ॱ();
                Object ॱॱ = ॱ2.ॱॱ();
                CharSequence spannableString = new SpannableString(ॱॱ);
                int lastIndexOf = ॱॱ.lastIndexOf(text2);
                if (lastIndexOf != -1) {
                    int length = lastIndexOf + text2.length();
                    ckl o_ckl = new ckl(context);
                    o_ckl.ˏ(new e(context, 2, false).ˎ());
                    spannableString.setSpan(o_ckl, lastIndexOf, length, 33);
                    spannableString.setSpan(new TextAppearanceSpan(context.getString(h.ˊ), 0, (int) textView2.getTextSize(), null, null), lastIndexOf, length, 33);
                }
                textView2.setText(spannableString);
                textView2.setMovementMethod(new c());
                textView2.setHighlightColor(context.getResources().getColor(axa.c.ˊ));
            }
        }
        return linearLayout;
    }

    private View ˎ(Context context) {
        LayoutInflater from = LayoutInflater.from(context);
        LinearLayout linearLayout = (LinearLayout) from.inflate(f.ʼ, null);
        linearLayout.setVisibility(8);
        LinearLayout linearLayout2 = (LinearLayout) linearLayout.findViewById(b.ˋˋ);
        LinearLayout linearLayout3 = (LinearLayout) linearLayout.findViewById(b.ˋˊ);
        TextView textView = (TextView) linearLayout.findViewById(b.ˎ);
        awr ॱ = axg.ˏ().ॱ();
        if (ॱ != null) {
            aws ˊ = ॱ.ˊ();
            if (ˊ != null) {
                textView.setText(ˊ.ˋ());
                LayoutParams layoutParams = new LinearLayout.LayoutParams(-2, -2);
                if (ˊ.ˊ() != null) {
                    for (d dVar : ˊ.ˊ()) {
                        LinearLayout linearLayout4 = (LinearLayout) from.inflate(f.ʽॱ, null);
                        TextView textView2 = (TextView) linearLayout4.findViewById(b.ᐝ);
                        ((TextView) linearLayout4.findViewById(b.ॱˊ)).setText(dVar.ˋ);
                        textView2.setText(dVar.ˏ);
                        linearLayout4.setLayoutParams(layoutParams);
                        linearLayout2.addView(linearLayout4);
                    }
                }
                if (ˊ.ˏ() != null) {
                    for (String text : ˊ.ˏ()) {
                        textView = (TextView) from.inflate(f.ˈ, null);
                        textView.setText(text);
                        textView.setLayoutParams(layoutParams);
                        linearLayout3.addView(textView);
                    }
                }
                View inflate = from.inflate(f.ͺ, null);
                textView = (TextView) inflate.findViewById(b.ॱᐝ);
                String ॱ2 = ˊ.ॱ();
                String ʼ = ˊ.ʼ();
                String ॱॱ = ˊ.ॱॱ();
                CharSequence spannableString = new SpannableString(ॱॱ);
                ayr.ॱ(context, spannableString, textView, ॱॱ, ॱ2, new e(context, 1, false).ˎ());
                ayr.ॱ(context, spannableString, textView, ॱॱ, ʼ, new e(context, 2, false).ˎ());
                textView.setText(spannableString);
                textView.setMovementMethod(new c());
                textView.setHighlightColor(context.getResources().getColor(axa.c.ˊ));
                ewb.ॱ((LinearLayout) linearLayout.findViewById(b.ॱॱ), inflate);
            }
        }
        return linearLayout;
    }

    public void ॱ() {
        if (this.ˊ != null && this.ˊ.getChildCount() > 0) {
            if (this.ˋ.ॱ != this.ˊ.getChildCount() - 1) {
                int i = this.ˋ.ॱ;
                axv o_axv = this.ˋ;
                o_axv.ॱ++;
                Animation translateAnimation = new TranslateAnimation(0.0f, (float) (-this.ˊ.getWidth()), 0.0f, 0.0f);
                translateAnimation.setDuration(250);
                translateAnimation.setFillAfter(true);
                this.ˊ.getChildAt(i).startAnimation(translateAnimation);
                this.ˊ.getChildAt(i).clearAnimation();
                this.ˊ.getChildAt(i).invalidate();
                this.ˊ.getChildAt(i).setVisibility(4);
                this.ˊ.getChildAt(this.ˋ.ॱ).setVisibility(0);
                this.ˊ.getChildAt(i).setVisibility(8);
                Animation translateAnimation2 = new TranslateAnimation((float) this.ˊ.getWidth(), 0.0f, 0.0f, 0.0f);
                translateAnimation2.setDuration(250);
                translateAnimation2.setFillAfter(true);
                this.ˊ.getChildAt(this.ˋ.ॱ).startAnimation(translateAnimation2);
            }
        }
    }

    public void ˊ() {
        if (this.ˊ != null && this.ˋ.ॱ != 0) {
            int i = this.ˋ.ॱ;
            axv o_axv = this.ˋ;
            o_axv.ॱ--;
            Animation translateAnimation = new TranslateAnimation(0.0f, (float) this.ˊ.getWidth(), 0.0f, 0.0f);
            translateAnimation.setDuration(250);
            translateAnimation.setFillAfter(true);
            this.ˊ.getChildAt(i).startAnimation(translateAnimation);
            this.ˊ.getChildAt(i).clearAnimation();
            this.ˊ.getChildAt(i).invalidate();
            this.ˊ.getChildAt(i).setVisibility(4);
            this.ˊ.getChildAt(this.ˋ.ॱ).setVisibility(0);
            this.ˊ.getChildAt(i).setVisibility(8);
            Animation translateAnimation2 = new TranslateAnimation((float) (-this.ˊ.getWidth()), 0.0f, 0.0f, 0.0f);
            translateAnimation2.setDuration(250);
            translateAnimation2.setFillAfter(true);
            this.ˊ.getChildAt(this.ˋ.ॱ).startAnimation(translateAnimation2);
        }
    }

    public boolean ˊ(int i, KeyEvent keyEvent) {
        if (i != 4 || this.ˋ.ॱ != 1) {
            return super.onKeyUp(i, keyEvent);
        }
        ˊ();
        return true;
    }
}
